package cn.liontalk.concurrent.shuati;

import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;


public class Main3 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            String key = sc.nextLine();
            if (key.contains(".")) {
                System.out.println(ipToNumber(key));
            } else {
                System.out.println(numberToIp(key));
            }
        }
        sc.close();

    }


    public static String ipToNumber(String key) {
        String[] a = key.split("\\.");
        StringBuffer stringBuffer = new StringBuffer();
        for (int i = 0; i < a.length; i++) {
            String result = Integer.toBinaryString(Integer.parseInt(a[i]));
            if (result.length() < 8) {
                result = appendO(result);
            }
            stringBuffer.append(result);
        }
        return String.valueOf(new BigInteger(stringBuffer.toString(), 2));

    }

    public static String appendO(String result) {
        StringBuffer sb = new StringBuffer();
        if (result.length() < 8) {
            for (int i = 0; i < (8 - result.length()); i++) {
                sb.append("0");
            }
        }
        sb.append(result);
        return sb.toString();
    }


    public static String numberToIp(String  key) {
        String s = Integer.toBinaryString(new BigInteger(key).intValue());
        s = appendO1(s);
        List<String> list = new ArrayList<>();
        for (int j = 0; j < 4; j++) {
            list.add((s.substring(8*j,8*j+8)));
        }
        StringBuffer stringBuffer = new StringBuffer();
        for (String s1: list ) {
            BigInteger b = new BigInteger(s1, 2);
            int a  =  b.intValue();
            stringBuffer.append(a+".");
        }
        return stringBuffer.toString().substring(0,stringBuffer.length()-1);
    }


    public static String appendO1(String result) {
        StringBuffer sb = new StringBuffer();
        if (result.length() < 32) {
            for (int i = 0; i < (32 - result.length()); i++) {
                sb.append("0");
            }
        }
        sb.append(result);
        return sb.toString();
    }


}
